package com.ruoyi.web.controller.nongjt;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.nongjt.domain.NjtUserRegister;
import com.ruoyi.nongjt.service.NjtUserRegisterService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nongjt/njtUserRegister")
public class NjtUserRegisterController extends BaseController {
    @Autowired
    private NjtUserRegisterService njtUserRegisterService;

    @GetMapping("/list")
    public TableDataInfo list(NjtUserRegister njtUserRegister){
        startPage();
        List<NjtUserRegister> list = njtUserRegisterService.selectNjtUserRegisterList(njtUserRegister);
        return getDataTable(list);
    }

    @PutMapping
    public AjaxResult update(@RequestBody NjtUserRegister njtUserRegister){
        int rows = njtUserRegisterService.updateNjtUserRegister(njtUserRegister);
        return toAjax( rows);
    }
    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable Long id) {
        int rows = njtUserRegisterService.deleteNjtUserRegisterById(id);
        return toAjax(rows);
    }
    @PostMapping("/export")
    public void export(HttpServletResponse response, NjtUserRegister njtUserRegister) {
        List<NjtUserRegister> list = njtUserRegisterService.selectNjtUserRegisterList(njtUserRegister);
        ExcelUtil<NjtUserRegister> util = new ExcelUtil<>(NjtUserRegister.class);
        util.exportExcel(response, list, "用户注册数据");
    }
}
